Tags: COM add blog electronic share mic int sig jpgModbus protocol display |modbus Communication display |modbus display electronic screen function code sharing, mainly used to achieve "preset multiple register function code." The "0X1F" function code of the MODBUS-RTU protocol is photographed as follows: An example of the "0X1F" function code for the MODBUS-RTU protocol is as follows: Example: The request is placed in 2 registers from the Modbus display device 17, the starting register is 4
Idd_test_dialog, Edit our main interface dialog box.Double click on "Phone", pop Up the following dialog box, press the Confirm key:VC will enter the source Code editing window, this function is used to handle the serial port event, when the PC serial port received data, will produce a data buffer has data message event, and then call to execute this function. Add the following code, for Data processing, window updates and other operations:VARIANT Variant1;//Define variant variables to hold the
:
void Uart1_sendstring (uint8_t* cp)
{
while ((*CP)! = ') ')
{
Usart1_send_isr (*CP);
cp++;
}
}
A function that sends a single character:
void Usart1_send_isr (uint8_t ch) {
usart_senddata (USART1, (uint8_t) ch);
while (Usart_getflagstatus (USART1, usart_flag_txe) = = RESET); Do you want the buffer to be sent after the decision?
}
Then open the send interrupt when the data is sent outside the interrupt function. Usart_itconfig (USART1, Usart_it_txe, EN
;Colesafearray safearray_indium;Longlen, K;Byte rxdata [1024]; // sets the byte arrayCstring strtemp;If (m_mscomm.getcommevent 0 = 2) // if the event value is 2, the data is received.{Variant_indium = m_mscomm.getinput 0; // read the bufferSafearray_indium = variant_indium;Len = safearray_inp.getonedimsize (); // obtain the valid data length.For (k = 0; k Safearray_inp.getelement ( K, rxdata + k); // conver
the contents of the edit boxM_ctrlcomm.put_output (COleVariant (m_strsend));//Send data}void Cmscommdlg::onbnclickedexit (){Todo:add your control notification handler code hereM_ctrlcomm.put_portopen (0);//close the serial portCdialog::oncancel ();//Exit Program}3, implement the MSComm control corresponding response function OnOnCommMsComm1 ()VARIANT Variant_inp;COleSafeArray Safearray_inp;LONG len,k;byte rxdata[2048];//setting byte arrayCString strt
function-- Used to display data received by the serial port { //todo:add your control notification handler code here variant VARIANT_INP; colesafearray SAFEARRAY_INP; long len,k; byte rxdata[2048];//Set BYTE array an 8-bit integerthat are not signed. cstring strtemp; cstring Strrxdata; strrxdata.empty (); if (m_gpscom. Getcommevent () ==2) //Event value 2 indicates that there is a character { variant_inp=m_gpscom in the receive buffer. G
the white side to go, right click on the phone icon Click Edit Control can be removed if(m_ctrlcomm.get_commevent () = =2)//an event value of 2 indicates a receive event{BYTE rxdata[255]={0};//Set byte arrayVARIANT Variant_inp=m_ctrlcomm.get_input ();//Read BufferCOleSafeArray SAFEARRAY_INP = VARIANT_INP;//Variant variable converted to COleSafeArray variable LongLen=safearray_inp. Getonedimsize ();//get valid data length for(Longk=0
characters, the oncomm event that receives data is triggered.M_mscomm.setsettings ("9600, N, 8, 1"); // The baud rate is 9600, which has no check bits, 8 data bits, and 1 Stop bits.If (! M_mscomm.getportopen () // open if the serial port is not enabledM_mscomm.setportopen (true); // open the serial portElseM_mscomm.setoutbuffercount (0 );// Control Event Response Declaration// *. H// {Afx_msg (cgolfview)Afx_msg bool oncomm ();Declare_eventsink_map ()//} Afx_msg// *. CppBegin_eventsink_map (cgol
;Colesafearray safearray_indium;Long Len, K;Byte rxdata [2048]; // sets byte array an 8-bit integerthat is not signed.Cstring strtemp;If (m_ctrlcomm.getcommevent () = 2) // if the event value is 2, the receiving buffer contains characters.{// The following code can be added based on your communication protocol.Variant_indium = m_ctrlcomm.getinput (); // read the bufferSafearray_indium = variant_indium; // convert a variable of the variant type to a va
boxM_ctrlcomm.put_output (COleVariant (m_strsend));//Send data}void Cmscommdlg::onbnclickedexit (){Todo:add your control notification handler code hereM_ctrlcomm.put_portopen (0);//close the serial portCdialog::oncancel ();//Exit Program}3. Implement the corresponding response function of MSComm control ONONCOMMMSCOMM1 ()VARIANT Variant_inp;COleSafeArray Safearray_inp;LONG len,k;byte rxdata[2048];//setting byte arrayCString strtemp;if (m_ctrlcomm.get
It mainly modifies the function type and is compatible with normal and enhanced interruptions.
The main functions are as follows:
(1) uart_regs.h
(2) mcu_uart.h
(3) mcu_uart.c
(4) sys_main.c
//--------------------------------------------------------------------------
/** Uart_regs.h** Created on: 2011-4-4* Author: crazybingo*/
# Ifndef uart_regs_h _# Define uart_regs_h _
# DEFINE _ UART
// --------------------------------------- typedef struct { Union { {> volatile unsign
1024
Static volatile int tx_done = 0;Volatile static alt_u8 CHR [char_length];
// Callback functionStatic void done (void * handle){Tx_done ++;}
Int main (){// Output destination address space data through the serial portInt I;For (I = 0; I {* (CHR + I) = I;}
// Create a DMA receiving ChannelAlt_dma_txchan txchan;// Source AddressVoid * source_buff_ptr = (void *) CHR;// Target address uart_base + 2, because the UART txdata register is after rxdata
loops. As long as users know how to use rgss, they can use the engine to make their own games smoothly.
This encapsulated content is transparent to users, and you do not need to understand it normally. However, for those who are eager to learn more, today we will discuss this part of J.
1.2 imaginary Structure
By default, a game contains at least three files: game.exe, game. ini, and rgssxxxx. dll. Come and guess. There is something in it (not a pure guess ).
Game.exe is the main game progra
...... /** Lan_nint configuration **/# define lan_nint_name "/dev/lan_nint" # define lan_nint_type "altera_avalon_pio" # define lan_nint_base 0x00201070 ......
We need the following content:
# Define lan_base 0x00201020 # define lan_cs_base 0x00201060 # define lan_nint_base 0x00201070
Next, we need to modify the System File System (. h) and add the followingCode
Typedef struct {volatile unsigned long int rxdata; volatile unsigned long int txda
{static unsigned char bt_rxdata_merge_status=bt_rxdata_merge_defaul_status;//means an IAP packet is sent by a bt_rxdata if (bt_ Rxdata_merge_status==bt_rxdata_merge_defaul_status 0x55==bt_rxdata->msgdata[2]) {//detect the length of the IAP packet First// IAP packet: Length field data contains 1 or 3 bytes, depending on the length of the payload//one-byte domain can behave in a single byte 0x02 to 0xFC (2 to 252) load length//Three bytes field data contains 0x00 tag bytes, 2 bytes payload Length
int receive_data: 8; volatile unsigned long int NC: 24;} bits; volatile unsigned long int word;} rxdata; // sending register Union {struct {volatile unsigned long int transmit_data: 8; volatile unsigned long int NC: 24;} bits; volatile unsigned long int word;} txdata; // Status Register Union {struct {volatile unsigned long int PE: 1; volatile unsigned long int Fe: 1; volatile unsigned long int BRK: 1; volatile unsigned long int ROE: 1; volatile unsi
++) {Checksum+=Commandtext[i]; } commandtext[ -]=checksum; Statusbyte= SendCommand (CommandText, +); returnStatusbyte;}( 4 ) Get file Information commandThis command provides the host with the ability to read the file pointer value and file size of the currently open file. The command encoding is: 0x09, and its command format is as follows://get file Info commandvoidgetfilestatus (uint8_t rxdata[]) {uint8_t commandtext[6]={0x55,0xAA,0x09,0x00,0x00,0x0
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.